package cn.eng.basic.controller;

import cn.eng.basic.domain.dto.LoginDto;
import cn.eng.basic.service.ILoginService;
import cn.eng.basic.utils.AjaxResult;
import cn.eng.user.service.ILogininfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private ILoginService loginService;

    /**
     * 账户登录
     * @param loginDto
     * @return
     */
    @RequestMapping("/account")
    public AjaxResult account(@RequestBody @Valid LoginDto loginDto){
        return loginService.account(loginDto);

    }

    /**
     * 微信扫码登录
     * @param code
     * @return
     */
    @RequestMapping("/wechat/{code}")
    public AjaxResult wechatLogin(@PathVariable("code") @Valid String code){
        return loginService.wechatLogin(code);

    }

    /**
     * 微信绑定
     * @param map
     * @return
     */
    @PostMapping("/wechat/binder")
    public AjaxResult wechatBinder(@RequestBody Map<String,String> map){
        return loginService.wechatBinder(map);
    }

}
